<?php

use common\server\BasicDataServer;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\HouseModel */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="house-model-form">

    <?php $form = ActiveForm::begin(); ?>

    <div class="row">
        <div class="col-lg-6">
            <?= $form->field($model, 'house_name')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'house_unit_price')->textInput() ?>

            <?= $form->field($model, 'return_money')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'developer')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'checkout')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'property')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'decoration_id')->dropDownList(BasicDataServer::instance()->getDecorationTypeToOptions()) ?>
            <?= $form->field($model, 'category_id')->dropDownList(BasicDataServer::instance()->getCategoryToOptions()) ?>

            <?= $form->field($model, 'house_area')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'floor_area')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'area_covered')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'total_price')->textInput() ?>

            <?= $form->field($model, 'payment_rate')->textInput(['maxlength' => 5]) ?>

            <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'region_id')->dropDownList(BasicDataServer::instance()->getRegionToOptions(), ['encodeSpaces' => 1]) ?>

            <div class="form-group field-housemodel-room">
                <label class="control-label" for="housemodel-total_price">户型</label>

                <div>
                    <input type="number" id="housemodel-room1" style="display: inline; width: 120px" class="form-control"
                           name="HouseModel[room1]" value="<?= empty($model->room1) ? '' : $model->room1 ?>">
                    -
                    <input type="number" id="housemodel-room2" style="display: inline; width: 120px" class="form-control"
                           name="HouseModel[room2]" value="<?= empty($model->room2) ? '' : $model->room2 ?>">
                    室
                    <div class="help-block"></div>
                </div>
            </div>



            <div class="form-group">
                <label for="longitude">经度/纬度</label>
                <div class="form-inline">
                    <?= $form->field($model, 'longitude',['labelOptions' => ['class' => 'sr-only']])->textInput(['style'=>'width:120px;','maxlength' => 9]).' , ' ?>
                    <?= $form->field($model, 'latitude',['labelOptions' => ['class' => 'sr-only']])->textInput(['style'=>'width:120px;','maxlength' => 9]) ?>
                </div>
            </div>

        </div>
        <div class="col-lg-6">
            <?= $form->field($model, 'discount_1')->textInput(['maxlength' => 6]) ?>

            <?= $form->field($model, 'discount_2')->textInput(['maxlength' => 6]) ?>
            <?= $form->field($model, 'head')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'plot_ratio')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'greening_rate')->textInput() ?>

            <?= $form->field($model, 'layout_number')->textInput() ?>

            <?= $form->field($model, 'car_number')->textInput() ?>

            <?= $form->field($model, 'building_type')->checkboxList(BasicDataServer::instance()->getBuildTypeToOptions()) ?>

            <?= $form->field($model, 'house_mark')->checkboxList(BasicDataServer::instance()->getHouseMarkToOptions()) ?>

            <?= $form->field($model, 'property_fee')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'property_company')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'return_day')->textInput(['maxlength' => 3]) ?>

            <?= $form->field($model, 'banner')->fileInput() ?>


            <?php
            if(!empty($model->banner)){
                echo "<img src='{$model->banner}' style='max-height: 200px; max-width: 200px'/><br/><br/>";
            }
            ?>

            <?= $form->field($model, 'adv')->fileInput() ?>

            <?php
            if(!empty($model->banner)){
                echo "<img src='{$model->adv}' style='max-height: 200px; max-width: 200px'/><br/><br/>";
            }
            ?>

            <?= $form->field($model, 'is_banner')->radioList(BasicDataServer::instance()->getYN()) ?>
            <?= $form->field($model, 'is_banner_home')->radioList(BasicDataServer::instance()->getYN()) ?>

            <?= $form->field($model, 'is_adv')->radioList(BasicDataServer::instance()->getYN()) ?>

            <?= $form->field($model,"is_recommend")->radioList(BasicDataServer::instance()->getIsRecommend()) ?>

            <?= $form->field($model, 'recommend_sort',['labelOptions' => ['label' => '推荐排序(数值越大越靠前)']])->textInput(['style'=>'width:80px;','maxlength'=>4]) ?>
        </div>
    </div>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
